package easy; /**
 * 相邻不超过1的最长值
 */

import java.util.Arrays;

public class test19 {
    public static void main(String[] args) {
        test19 test19 = new test19();
        System.out.println(test19.runeReserve(new int[]{1,3,5,4,1,7}));
    }

    public int runeReserve(int[] runes) {
        Arrays.sort(runes);
        int c = 0, max = 0;
        for (int i = 1; i < runes.length; i++) {
            if (runes[i] - runes[i - 1] <= 1) {
                max = Math.max(max, ++c);
            } else {
                c = 0;
            }
        }
        return max+1;
    }
}
